$(document).ready(function () {

    var url = window.location.href;//获取url
    var files = window.location.pathname;//获取url路径
    var query = window.location.search;//获取url参数
    // 测试用URL

    var getUrl = "http://api.shur.cn/v1/skills/challenges/44?access_token=e3f9595e4559bceeda28514ba624b7ca290229c1&expand=userStatus";

    //var url = "http://api.shur.cn/v1/skills/challenges?id=44&type=userStatus";
    if (checkUrl(getUrl)) {
        get(getUrl,"GET", {
            loading: function () {
                console.log('加载中。。。');
            },
            success: function (data) {
                console.log('回调-data:' + data);
                init(data);
            },
            error: function () {
                console.log('加载失败');
            }
        });
    }


    function init(data) {
        var title = data.title;
        var badge_id = data.badge_id;
        var body = data.body;
        var attachments = data.attachments;
        var poster_url = attachments[0].poster_url;
        var is_video = attachments[0].is_video;
        var url = attachments[0].url;
        console.log(url);
        console.log(title);
        console.log(badge_id);
        console.log(body);
        console.log(poster_url);
        console.log(is_video);
        console.log(url);
        $('#activity-title').text(title);
        $('title').html(title);
        $('#activity-content').html(body);
        if (is_video == 1) {
            var options = {
                controls: true,
                url: url,
                poster: poster_url,
                type: 'hls',
                preload: true,
                autoplay: false // 如为 true，则视频将会自动播放
            };
            var player = new QiniuPlayer('shur-video', options);
        }

    }
    $('#btn-up-app').click(function () {
        console.log("app-btn-click");
        // var scheme = "scheme://host/pathPrefix?id=44";
        var scheme = "scheme://host/pathPrefix";
        startApp(scheme);
    });




});
